<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Company extends Model
{
    //
	protected $table='company';
	protected $fillable=[
		'name','organization_code','address','linkman','phone',
		'contract_code','start_time','end_time','salesman','license','status'
	];


	public function lists($where){
		$res=$this->where(function ($query) use($where){
			if($where['name'] !=null ){
				$query->where('name','like','%'.$where['name'].'%');
			}
			if($where['start_time'] !=null ){
				$query->where('created_at','>',$where['start_time']);
			}
			if($where['end_time'] !=null ){
				$query->where('created_at','<',$where['end_time']);
			}
			if($where['status'] !=null ){
				$query->where('status','=',$where['status']);
			}
			if($where['status'] !=null ){
				$query->where('status','=',$where['status']);
			}
		})->paginate(config('app.config'));
		return $res;
	}
}
